<?php

class Application_Form_Edit extends Zend_Form
{	
	public function Application_Form_Edit($user,$page)
	{
		$this->setName("Edit");
			
		$login = new Zend_Form_Element_Text("editLogin");
		//$login->setLabel("Pseudo");
		$login->setAttrib("class", "inp-form");
		$login->setValue($user['login']);
		$login->setAttrib("readOnly", "true");
		
		$password = new Zend_Form_Element_Password("editPassword");
		$password->setAttrib("class", "inp-form");
		//$password->setLabel("Password");
		
		
		$verifPassword = new Zend_Form_Element_Password("editVerifPassword");
		//$verifPassword->setLabel("Verification Password");
		$verifPassword->setAttrib("class", "inp-form");
		
		
		$fname = new Zend_Form_Element_Text("editFname");
		//$fname->setLabel("Nom");
		$fname->setAttrib("class", "inp-form");
		$fname->setValue($user['fname']);
		
		$lname = new Zend_Form_Element_Text("editLname");
		//$lname->setLabel("Prenom");
		$lname->setAttrib("class", "inp-form");
		$lname->setValue($user['lname']);
		
		
		$email=new Zend_Form_Element_Text("editEmail");
		//$email->setLabel("Email :");
		$email->setAttrib("class", "inp-form");
		$email->setValue($user['email']);
		
		$role = new Zend_Form_Element_Select("editRole");
		//$role->setLabel("Groupe : ");
		$role->setAttrib("class", "styledselect_form_1");
		
		$email->setAttrib("class", "inp-form");
		$role->addMultiOption("Admin","Admin");
		$role->addMultiOption("Manager","Manager");
		$role->addMultiOption("Collaborateur","Collaborateur");
		$role->addMultiOption("Responsable","Responsable");
		$role->setValue($user['role']);
		
		$responsable = new Zend_Form_Element_Select("editResponsable");
		$responsable->setAttrib("class", "styledselect_form_1");
		$responsable->setRequired(true);
		$responsable->addMultiOption($user['id'],$user['id_resp']);
		
		$table = new Application_Model_DbTable_Utilisateur();
		
		foreach ( $table->getUsers() as $c)
		{
			$responsable->addMultiOption($c->id, $c->lname);
		}
		
		$editButton = new Zend_Form_Element_Submit("editButton");
		$responsable->setAttrib("class", "styledselect_form_1");
		//$editButton->setLabel("Edit");
		$editButton->setAttrib("class", "form-submit");
		
		
		$annulerButton = new Zend_Form_Element_Button("annulerEditButton");
		$annulerButton->setAttrib("class", "form-reset");
		if ($page==0)
		$annulerButton->setLabel("Annuler")->setAttrib("onClick", "window.location='main'");
		else
		$annulerButton->setLabel("Annuler")->setAttrib("onClick", "window.location='../../main'");

		$resetButton = new Zend_Form_Element_Reset("resetButton");
		$resetButton->setLabel("Effacer");
		
		$this->addElements(array($login,$password,$verifPassword,$fname,$lname,$email
		,$role,$responsable,$editButton,$annulerButton,$resetButton));
		
	}
}
